package com.my.chapter18;

import net.mindview.util.ProcessFiles;

import java.io.File;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import java.util.Locale;

public class practice6 {
    public static void main(String[] args) throws ParseException {
        Date dt = new Date();

        FilesModified.main(new String[]{".//src//com//my//chapter18","2021-7-11 06:16:36"});
    }
}

class FilesModified{
    public static void main(String[] args) {
        DateFormat df = DateFormat.getDateInstance(
                DateFormat.SHORT, Locale.CHINA);
        if(args.length != 2) {
            System.err.println(
                    "Usage: java E06_ProcessFiles3 path date");
            return;
        }
        long tmp = 0;
        try {
            df.setLenient(false);//用于设置或取消设置日期或时间解释的宽松状态。
            tmp = df.parse(args[1]).getTime();
        } catch(ParseException pe) {
            pe.printStackTrace();
            return;
        }
        final long modTime = tmp;
        new ProcessFiles(new ProcessFiles.Strategy() {
            @Override
            public void process(File file) {
                if(modTime < file.lastModified())
                    System.out.println(file);
            }
        }, "java").start(new String[] {args[0]});
    }
}
